package com.project.base.baseproject.AppCustoms.LoadingUpView;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.project.base.baseproject.R;

/**
 * Created by mac on 2017/7/11.
 */
//请求加载指示器
public class LoadingDialog {
    LVCircularRing mLoadingView;
    Dialog mLoadingDialog;
    Context mContext;

    public LoadingDialog(Context context) {
        // 首先得到整个View
        mContext = context;
        View view = LayoutInflater.from(context).inflate(
                R.layout.loading_dialog_view, null);
        // 页面中的LoadingView
        mLoadingView = (LVCircularRing) view.findViewById(R.id.lv_circularring);
        // 页面中显示文本
        // 创建自定义样式的Dialog
        mLoadingDialog = new Dialog(context, R.style.loading_dialog);
        // 设置返回键有效
        mLoadingDialog.setCancelable(true);
        mLoadingDialog.setContentView(view, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT));
    }
    public void show(){
        mLoadingDialog.show();
        mLoadingView.startAnim();
    }
    public void close(){
        if(mLoadingDialog == null)
            return;
        mLoadingView.stopAnim();
        mLoadingDialog.dismiss();
    }
}
